﻿using System;
using System.Xml.Serialization;

namespace Draco.OWF.Metadata
{
    public class RouteModel
    {
        protected String m_Id = Guid.NewGuid().ToString();

        public RouteModel()
        {
            this.TransitionType = "Default";
        }

        public RouteModel(String fromId, String toId)
            : this("", fromId, toId){ }
        public RouteModel(String id, String fromId, String toId)
        {
            if (String.IsNullOrEmpty(fromId))
                throw new ArgumentNullException("argument fromId is empty");
            if (String.IsNullOrEmpty(toId))
                throw new ArgumentNullException("argument toId is empty");
            this.Id = id;
            this.FromId = fromId;
            this.ToId = toId;
            this.TransitionType = "Default";
        }

        [XmlAttribute("id")]
        public virtual string Id
        {
            get { return m_Id; }
            set
            {
                if (!String.IsNullOrEmpty(value))
                    m_Id = value;
            }
        }

        [XmlAttribute("from")]
        public virtual string FromId { get; set; }

        [XmlAttribute("to")]
        public virtual string ToId { get; set; }

        [XmlAttribute("type")]
        public String TransitionType { get; set; }
    }
}
